#include "stdafx.h"
#include "UTexturedWindow.h"
#include "ULeafWindow.h"
#include "UTextureManager.h"

TTexturedWindow::TTexturedWindow()
: TCustomWindow(false)
{
	texture = GTextureManager->getTexture("defaulttexture.png");
}

TTexturedWindow::TTexturedWindow(std::string textureName)
: TCustomWindow(false)
{
	texture = GTextureManager->getTexture(textureName);
}

void TTexturedWindow::Draw( ) {
	int width  = Parent->Right-Parent->Left;
	int height = Parent->Bottom-Parent->Top;
	static int rotation=0;

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture);
	glColor3f(1.0,1.0,1.0);

	glBegin( GL_QUADS );
	glTexCoord2i(0,0); glVertex2i( 0, 0 );
	glTexCoord2i(1,0); glVertex2i( width, 0 );
	glTexCoord2i(1,1); glVertex2i( width, height );
	glTexCoord2i(0,1); glVertex2i( 0, height );
	glEnd();

	glDisable(GL_TEXTURE_2D);
	glLoadIdentity();
}
